#pragma once
#include"HashTable.h"

namespace szt
{
	template<class K, class HashFunc = Hash<K>>
	class unordered_set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename LinkHash::HashTable<K, K, SetKeyOfT, HashFunc>::iterator iterator;
		iterator begin()
		{
			return sht.begin();
		}

		iterator end()
		{
			return sht.end();
		}

		bool erase(const K& key)
		{
			return sht.Erase(key);
		}

		bool insert(const K& key)
		{
			return sht.Insert(key);
		}

	private:
		LinkHash::HashTable<K, K, SetKeyOfT, HashFunc> sht;
	};

	void test()
	{
		unordered_set<int> uns;
		uns.insert(4);
		uns.insert(14);
		uns.insert(34);
		uns.insert(7);
		uns.insert(24);
		uns.insert(17);
		uns.insert(54);
		uns.insert(94);
		uns.insert(37);
		uns.insert(87);
		uns.insert(64);
		uns.erase(34);
		unordered_set<int>::iterator it = uns.begin();
		while (it != uns.end())
		{
			cout << *it << ' ';
			++it;
		}
		cout << endl;
	}
}